package com.first.statistics.service.impl;


import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.first.common.pojo.Order;
import com.first.common.pojo.TbMember;
import com.first.statistics.dao.StatOrderDao;
import com.first.statistics.service.StatOrderService;
import com.first.statistics.vo.TbMemberVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * @program: SecondProject
 * @description:
 * @author: 李榕轩
 * @create: 2023-05-30 09:00
 **/
@Service
public class StatOrderServiceImpl implements StatOrderService {
    @Autowired
    private StatOrderDao statOrderDao;

    @Override
    public List<Order> queryAll(TbMemberVo tbMemberVo) {
        QueryWrapper<Order> wrapper = new QueryWrapper<>();
//        String createTimeStart = tbMemberVo.getGmtCreate() + "-01-01 00:00:00";
//        String createTimeEnd = tbMemberVo.getGmtModified() + "-01-01 00:00:00";
//        if (StrUtil.isNotBlank(tbMemberVo.getGmtCreate()) && StrUtil.isNotBlank(tbMemberVo.getGmtModified()) ){
//            wrapper.between("gmt_create",createTimeStart,createTimeEnd);
//        }
        if (StringUtils.hasText(tbMemberVo.getGmtCreate())) {
            wrapper.ge("year(gmt_create)", tbMemberVo.getGmtCreate());
        }
        if (StringUtils.hasText(tbMemberVo.getGmtModified())) {
            wrapper.le("year(gmt_create)", tbMemberVo.getGmtModified());
        }
        List<Order> orders = statOrderDao.selectList(wrapper);
        return orders;
    }
}
